<?php
/**
 * Created by PhpStorm.
 * User: HLG
 * Date: 2019/10/14
 * Time: 16:47
 */
namespace app\api\model;
use think\Model;
use app\api\model\Classification;

class Mining extends BaseModel
{
    protected $table = 'content_user_mine';

    public function  getMininge($uid){
        $data=$this->where('user_id',$uid)->order('id desc')->select();
        foreach ($data as $key=>$value){
            $order=Classification::where(['id'=>$value['mine_id']])->find();
            $start=date('Y-m-d H:i:s',$order['create_time']);
            $end=strtotime($start.' +'.$order['end_days'].' day');
            if(time() > $end ){
                unset($data[$key]);
            }else{
                $Date_1 = date("Y-m-d");
                $d1 = strtotime($Date_1);
                $Days = round(($end-$d1)/3600/24);
                $data[$key]['time']=$Days; //到期时间
            }
            if($value['state']==1){
                $data[$key]['dealTime']=time_diff(time(),$value['end_time']);
            }
        }
       return $data;
    }
}